package com.wanghongli.week2house.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanghongli.week2house.entity.House;
import com.wanghongli.week2house.service.IHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whl
 * @since 2021-04-28
 */
@RestController
@RequestMapping("/house")
public class HouseController {
    @Autowired
    private IHouseService service;

    @RequestMapping("/getbyid")
    public House getbyid(@RequestParam("id")int id){
        House byId = service.getById(id);
        return byId;
    }

    @RequestMapping("getbyhnum")
    public Integer getbyhnum(@RequestParam("hnum")String hnum){
        QueryWrapper queryWrapper=new QueryWrapper();
        if (hnum!=null && hnum!=""){
            queryWrapper.eq("hnum",hnum);
        }
        House one = service.getOne(queryWrapper);
        return one.getId();
    }

}

